package java4s;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintStream;
import java.net.ServerSocket;
import java.net.Socket;

public class Server1 {
	public static void main(String args[]) throws IOException{
		ServerSocket ss=new ServerSocket(777);
		
		Socket s=ss.accept();
		System.out.println("connection established");
		OutputStream obj=s.getOutputStream();
		PrintStream ps=new PrintStream(obj);
		InputStream ob=s.getInputStream();
		BufferedReader br=new BufferedReader(new InputStreamReader(ob));
		BufferedReader kb=new BufferedReader(new InputStreamReader(System.in));
		while(true){
			String str,str1;
			while((str=br.readLine())!=null){
				System.out.println(str);
				str1=kb.readLine();
				ps.println(str1);
			}
			ps.close();br.close();
			kb.close();ss.close();s.close();
			System.exit(0);
			
		}
		
		
	}


}
